﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.Kinect.Nui;

namespace Kinductor
{
    public static class VectorHelper
    {
        public static Vector Add(this Vector left, Vector right)
        {
            return new Vector()
            {
                X = left.X + right.X,
                Y = left.Y + right.Y,
                Z = left.Z + right.Z,
                W = left.W + right.W
            };
        }

        public static Vector Subtract(this Vector left, Vector right)
        {
            return new Vector() { X = left.X - right.X, 
                                  Y = left.Y - right.Y, 
                                  Z = left.Z - right.Z, 
                                  W = left.W - right.W };
        }

        public static float Magnitude(this Vector v)
        {
            return (float)Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
        }

        public static Vector Divide(this Vector left, double divisor)
        {
            return new Vector()
            {
                X = (float)(left.X / divisor),
                Y = (float)(left.Y / divisor),
                Z = (float)(left.Z / divisor),
                W = (float)(left.W / divisor)
            };
        }
    }
}
